<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            选择盘点单号
        </div>
    </header>
    <script id="billcodeTemp" type="text/x-dot-template">

        {{~ it:value:index}}
        <li class="aui-list-item" onclick="setBillCode('{{= it[index].sysid }}','{{= it[index].billcode }}');">
            <div class="aui-list-item-inner">
                <div class="aui-list-item-title">{{= it[index].billcode }}</div>
            </div>
        </li>
        {{~}}

    </script>
    <div class="aui-content aui-margin-b-15" style="margin-top:50px;">
        <div class="aui-searchbar" id="search" style="position: relative;">
            <div class="aui-searchbar-input aui-border-radius">
                <i class="aui-iconfont aui-icon-search"></i>
                <div class="aui-searchbar-input">
                    <form action="javascript:doSearch();">
                        <input type="search" placeholder="请输入盘点单号" id="billCodeS">
                    </form>
                </div>
            </div>
            <div class="aui-btn aui-btn-primary" style="margin-right: 0.5rem;background-color: #03a9f4" onclick="doSearch()">搜索</div>
        </div>
        <ul class="aui-list aui-list-in" id="billcodelist">

        </ul>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
    apiready = function() {
        doSearch();
    };

    //选则返回函数
    function setBillCode(sysid, billcode) {
        api.closeWin();
        var name = api.pageParam.name;
        //操作状态
        var type = api.pageParam.type;
        if(type == "onLine"){
            api.execScript({
                name: name,
                script: 'setBillCode("' + sysid + '","' + billcode + '")'
            });
        }else{
            api.execScript({
                name: name,
                script: 'setBillCode("' + sysid + '","' + billcode + '")'
            });
        }
            

    }

    //搜索
    function doSearch() {
        
        var billCodeS = $("#billCodeS").val();
        var serverUrl = localStorage.getItem('serverUrl');
        var un = localStorage.getItem("un");
        var url = serverUrl + "/app/getbillCodes";
        var data = {
            values: { ////以表单方式提交参数（JSON对象）
                billCode: billCodeS,
                un: un,
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function(ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0') {
                    var mydata = eval(myobj.list);
                    var evaluation = doT.template($api.dom('#billcodeTemp').innerHTML);
                    $api.dom('#billcodelist').innerHTML = evaluation(mydata);
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }

    //返回按钮
    function closeWin() {
        api.closeWin({});
    }
</script>

</html>
